/*
 * Copyright 2010, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef PLLINKEDLISTNODE_H
#define PLLINKEDLISTNODE_H

#include <tools/PLListNode.h>

namespace PLSDK {
    
    /**
     * Linked list node.
     */
    template<typename T>
    class PLLinkedListNode : public PLListNode<T> {
    public:
        /**
         * Constructor.
         */
        PLLinkedListNode() : PLListNode<T>(), m_previous(0) {}
        /**
         * Constructor.
         *
         * @param _content The content for the node.
         */
        PLLinkedListNode(T _content) : PLListNode<T>(_content), m_previous(0) {}
        /**
         * Destructor.
         */
        inline virtual ~PLLinkedListNode() {}
        /**
         * Get the previous node.
         *
         * @return The previous node.
         */
        inline PLLinkedListNode<T> *previous();
        /**
         * Set the previous node.
         *
         * @param previous The previous node.
         */
        inline void setPreviousNode(PLLinkedListNode<T> *previous);
        /**
         * Is the node node the same as this node.
         */
        inline bool operator == (PLLinkedListNode<T> &node);
        /**
         * Is the node node not the same as this node.
         */
        inline bool operator != (PLLinkedListNode<T> &node);
    private:
        PLLinkedListNode<T> *m_previous;
    };

    template<typename T>
    PLLinkedListNode<T> *PLLinkedListNode<T>::previous() {
        return m_previous;
    }

    template<typename T>
    void PLLinkedListNode<T>::setPreviousNode(PLLinkedListNode<T> *_previous) {
        m_previous = _previous;
    }

    template<typename T>
    bool PLLinkedListNode<T>::operator == (PLLinkedListNode<T> &node) {
        if(node.next() == PLListNode<T>::m_next) {
            return true;
        }
        return false;
    }

    template<typename T>
    bool PLLinkedListNode<T>::operator != (PLLinkedListNode<T> &node) {
        if(node.next() != PLListNode<T>::m_next) {
            return true;
        }
        return false;
    }

}

#endif
